import { Vue, Component, Watch } from 'vue-property-decorator'
import XHeader from 'vux/src/components/x-header'
@Component({
    template: require('./login.html'),
    components: { XHeader }
})
export default class Login extends Vue {
    nickname: string = "";

    enter() {
        if (this.nickname === "") {
            this.$vux.toast.show({
                type: 'text',
                width: "8rem",
                position: 'top',
                text: '请输入昵称！'
            });
            return;
        }
        this.$socket.emit("login", {
            name: this.nickname
        });
        this.$emit('changeView', { viewName: "ChatRoom", nickName: this.nickname });
        // this.$router.push({ path: `/chatRoom`, query: { nickname: this.nickname } });
    }

    // goBack() {
    //     window.history.length > 1
    //         ? this.$router.go(-1)
    //         : this.$router.push('/')
    // }
}
